package com.minimalist.lindi.controller;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.contracttemplatefieldoption.LindiContractTemplateFieldOptionQueryVO;
import com.minimalist.common.entity.lindi.vo.contracttemplatefieldoption.LindiContractTemplateFieldOptionVO;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import com.minimalist.lindi.service.LindiContractTemplateFieldOptionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 林地指标平台_合同模板字段选项控制器
 *
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标平台_合同模板字段选项管理")
@RequestMapping("/lindi/contractTemplateFieldOption")
public class LindiContractTemplateFieldOptionController{

    @Autowired
    private LindiContractTemplateFieldOptionService service;

    @PostMapping("/addContractTemplateFieldOption")
    @Operation(summary = "添加合同模板字段选项")
    public R<?> addContractTemplateFieldOption(
            @RequestBody @Validated(Add.class)
            LindiContractTemplateFieldOptionVO contractTemplateFieldOptionVO){
        service.addContractTemplateFieldOption(contractTemplateFieldOptionVO);
        return R.ok();
    }

    @DeleteMapping("/deleteContractTemplateFieldOptionByContractTemplateFieldOptionId")
    @Operation(summary = "删除合同模板字段选项 -> 根据合同模板字段选项ID删除")
    public R<?> deleteContractTemplateFieldOptionByContractTemplateFieldOptionId(
            @RequestParam("contractTemplateFieldOptionId")
            @NotNull(message = "合同模板字段选项ID不能为空")
            @Parameter(name = "contractTemplateFieldOptionId", required = true, description = "合同模板字段选项ID")
            Long contractTemplateFieldOptionId){
        service.deleteContractTemplateFieldOptionByContractTemplateFieldOptionId(contractTemplateFieldOptionId);
        return R.ok();
    }

    @PutMapping("/updateContractTemplateFieldOptionByContractTemplateFieldOptionId")
    @Operation(summary = "修改合同模板字段选项")
    public R<?> updateContractTemplateFieldOptionByContractTemplateFieldOptionId(
            @RequestBody @Validated(Update.class)
            LindiContractTemplateFieldOptionVO contractTemplateFieldOptionVO){
        service.updateContractTemplateFieldOptionByContractTemplateFieldOptionId(contractTemplateFieldOptionVO);
        return R.ok();
    }

    @GetMapping("/getPageContractTemplateFieldOptionList")
    @Operation(summary = "查询合同模板字段选项列表(分页)")
    public R<PageResp<LindiContractTemplateFieldOptionVO>>
    getPageContractTemplateFieldOptionList(
            @RequestBody LindiContractTemplateFieldOptionQueryVO queryVO){
        return R.ok(service.getPageContractTemplateFieldOptionList(queryVO));
    }

    @GetMapping("/getContractTemplateFieldOptionByContractTemplateFieldOptionId/{contractTemplateFieldOptionId}")
    @Operation(summary = "根据合同模板字段选项ID查询合同模板字段选项")
    public R<LindiContractTemplateFieldOptionVO> getContractTemplateFieldOptionByContractTemplateFieldOptionId(
            @PathVariable(value = "contractTemplateFieldOptionId")
            @NotNull(message = "合同模板字段选项ID不能为空")
            @Parameter(name = "contractTemplateFieldOptionId", description = "合同模板字段选项ID", required = true)
            Long contractTemplateFieldOptionId){
        return R.ok(service.getContractTemplateFieldOptionByContractTemplateFieldOptionId(contractTemplateFieldOptionId));
    }
}